package kr.co.shoppingmall.shop;

import java.util.HashMap;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class ShopDAOImpl extends SqlMapClientDaoSupport implements ShopDAO {

    @Override
    public List<ShopDTO> getProductList(String category) {
	return getSqlMapClientTemplate().queryForList("shop.getProductList", category);
    }

    @Override
    public ShopDTO getProductDetail(String prodCode) {
	return (ShopDTO) getSqlMapClientTemplate().queryForObject("shop.getProductDetail", prodCode);
    }

    @Override
    public List<PurchasedDTO> getPurchasedList(String memId) {
	return getSqlMapClientTemplate().queryForList("shop.getpurchasedList", memId);
    }

    public int getProductCount(String category) {
	return (int) getSqlMapClientTemplate().queryForObject("shop.getProductCount", category);
    }

    @Override
    public void order(PurchasedDTO dto) {
	System.out.println(dto.getPurMemId());
	System.out.println(dto.getPurProdCode());
	System.out.println(dto.getPurQuantity());
	getSqlMapClientTemplate().insert("shop.order", dto);
    }
}
